#!/usr/bin/env bash
env=$1

# where the *.jar is put
cd /home/services/bin
 
if [ -z '${env}' ];
      then env='dev'
fi
 
# jacoco port
if [ "$JACOCO_PORT" != "" ]; then
     export JAVA_OPT=" -javaagent:/opt/jacoco/lib/jacocoagent.jar=output=tcpserver,address=0.0.0.0,port=16031"
fi
 
# java start parameters
JAVA_OPT="${JAVA_OPT}  -Xms1g -Xmx1g
                -XX:MetaspaceSize=2g
                -XX:MaxMetaspaceSize=2g
                -XX:+PrintGCDetails
                -Xloggc:/home/services/logs/gc.log
                -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps
                -XX:+UseG1GC
                -Dspring.profiles.active=${env}
                -jar *.jar"
PROG=$JAVA_HOME/bin/java

nohup $PROG ${JAVA_OPT} > /home/services/logs/start.log  2>&1 &
